#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
bool prime(long n)
{
    if(n == 1 || n == 0 || n < 0)
        return false;
    for(long i = 2; i*i<=n; i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}

int main()
{
    int L,K;
    cin >> L >> K;
  
    string s;
    getline(cin, s);
    getline(cin,s);
    if(L<K || s.size()<L ||K <= 0 || L <=0)
    {
        cout << "404";
        return 0;
    }  
   
    bool ifFind = false;
    for(long i = 0; i<=s.size()-K; i++)
    {
        string s1 = s.substr(i,K);
        //cout << s1<< endl;
        stringstream ss;
        ss << s1;
        long tl;
        ss >> tl;
        
        if(prime(tl) ==true)
        {
            cout << s1 << endl;
            ifFind = true;
            break;
        }
        
    }
    if(ifFind == false)
        cout << "404" << endl;
}